import request from '@/config/axios'

// 平台订单 VO
export interface OrderVO {
  id: number // ID
}

// 平台订单 API
export const OrderApi = {
  // 查询平台订单分页
  getOrderPage: async (params: any) => {
    return await request.get({ url: `/wo/order/page`, params })
  },

  // 查询平台订单详情
  getOrder: async (id: number) => {
    return await request.get({ url: `/wo/order/get?id=` + id })
  },

  // 新增平台订单
  createOrder: async (data: OrderVO) => {
    return await request.post({ url: `/wo/order/create`, data })
  },

  importOrder: async (data?: Array<number>) => {
    return await request.post({ url: `/wo/order/import`, data })
  },

  // 修改平台订单
  updateOrder: async (data: OrderVO) => {
    return await request.put({ url: `/wo/order/update`, data })
  },

  confirmOrder: async (data: OrderVO) => {
    return await request.post({ url: `/wo/order/confirm`, data })
  },

  settleOrder: async (data: OrderVO) => {
    return await request.post({ url: `/wo/order/settle`, data })
  },

  cancelOrder: async (data: OrderVO) => {
    return await request.post({ url: `/wo/order/cancel`, data })
  },

  // 删除平台订单
  deleteOrder: async (id: number) => {
    return await request.delete({ url: `/wo/order/delete?id=` + id })
  },

  // 导出平台订单 Excel
  exportOrder: async (params) => {
    return await request.download({ url: `/wo/order/export-excel`, params })
  },

  // ==================== 子表（订单明细） ====================

  // 获得订单明细列表
  getOrderItemListByOrderId: async (orderId) => {
    return await request.get({ url: `/wo/order/order-item/list-by-order-id?orderId=` + orderId })
  },

  // ==================== 子表（利润分配） ====================

  // 获得利润分配列表
  getRewardListByOrderId: async (orderId) => {
    return await request.get({ url: `/wo/order/reward/list-by-order-id?orderId=` + orderId })
  },

  // ==================== 子表（团队业绩） ====================

  // 获得团队业绩列表
  getTeamShareListByOrderId: async (orderId) => {
    return await request.get({ url: `/wo/order/team-share/list-by-order-id?orderId=` + orderId })
  }
}
